Repository navigation
Give programs an empty stdin by default, with -InheritStdin to opt out - #86
Merged
Merged
Conversation
Programs the kit starts inherited PowerShell's own stdin, so one that reads its input could take input meant for the script, or wait for it until its time limit. They now get NUL (on the Process.Start path, a closed pipe). -InheritStdin, or a command's InheritStdin key, gives PowerShell's own back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Programs the kit starts inherited PowerShell's own stdin. With the script's stdin piped or redirected in, a program that reads its input took input meant for the script; one that waits for input sat until its time limit, or forever without one.
Process.Startfallback. One that reads it gets the end of input straight away.-InheritStdinonStart-PkProcess,Invoke-PkProcessWithTimeout,Invoke-PkProcessBatchandInvoke-PkProcessDispatchpasses PowerShell's own stdin on, as before. A command's or job's ownInheritStdinkey ($true/$false) overrides it either way, and a bad value is a failed start, as withMaxOutputChars. Scripts using that key name for something of their own need to rename it.timeout.exerefuses to run without a console as its stdin, socmd /c timeout /t 5fails at once now. The README says so and suggestsping -n 6 127.0.0.1 >nul;-InheritStdinhelps only if the script's own stdin is a console.Process.Startitself writes a byte-order mark into the redirected stdin, so it isn't quite empty there.TypesVersiongoes to 13.Tested
New harness section BI starts a fresh PowerShell with a file as its stdin, on both start paths, and checks what
set /preads through each of the four functions and both per-command keys, plustimeout.exeand a UTF-8 console.set /pread the script's lines ([line1]to[line4]) through all four functions; 29 of the section's assertions failed, counting the ones for the new parameter.🤖 Generated with Claude Code